﻿using Xamarin.Forms;

namespace Games.Common
{
    public static class EnumHelper
    {
        public static Direction ToDirection(this SwipeDirection swipeDirection)
        {
            return (Direction)(int)swipeDirection;
        }

        public static Direction Reverse(this Direction direction)
        {
            switch(direction)
            {
                case Direction.Right:
                    return Direction.Left;
                case Direction.Left:
                    return Direction.Right;
                case Direction.Up:
                    return Direction.Down;
                case Direction.Down:
                    return Direction.Up;
                case Direction.Down | Direction.Right:
                    return Direction.Up | Direction.Left;
                case Direction.Down | Direction.Left:
                    return Direction.Up | Direction.Right;
                case Direction.Up | Direction.Right:
                    return Direction.Down | Direction.Left;
                case Direction.Up | Direction.Left:
                    return Direction.Down | Direction.Right;
            }
            return direction;
        }
    }
}
